Skip to content

[Prefabs] Modifier implementation #5#597

Open
EulalieCoevoet wants to merge 49 commits intosofa-framework:25_04_work_on_new_prefabsfrom
EulalieCoevoet:dev_prefabs
Open

[Prefabs] Modifier implementation #5#597
EulalieCoevoet wants to merge 49 commits intosofa-framework:25_04_work_on_new_prefabsfrom
EulalieCoevoet:dev_prefabs

Conversation

@EulalieCoevoet
Copy link
Copy Markdown
Contributor

@EulalieCoevoet EulalieCoevoet commented Mar 5, 2026

Proposition:
Introduce the create method to instantiate a Node, Entity, EntityModifier or Component(?) without adding it to the scene graph.
Thus to apply an EntityModifier to entities, we need to first create it and then call the apply method.
Adding an EntityModifier with the method add should raise an error.

In case of a EntityModifier:

  • create: instantiate the object and store its creator
  • apply: add the modifier to the scene graph, in creator\Modifiers, and in or near the modified entities depending on the modifications applied. And apply the method modifier.

Exemple:

See examples/stlib/EulalieScene.py.

def createScene(rootnode):

    simulation = addSimulationSettings(rootnode) # adds the default header (with solvers)

    cube1 = simulation.add(Entity, parameters=EntityParameters(name = "FixedCube"))
    cube2 = simulation.add(Entity, parameters=EntityParameters(name = "FallingCube"))
    
    simulation.create(SingleEntityModifier, parameters=FixingModifierParameters()).apply(entity=cube1) # one line example
image

In this PR:

  • Implementation of the create method
  • Implementation of the BaseEntityModifier, SingleEntityModifier, and FixingModifierParameters
  • Implementation of the discussed addSimulationSettings and the methods to register the required solvers.
  • Unifies the writing of dataclasses: class parameters instead of changing the signature of the __init__ method
  • Makes the default Entity a rigid cube
  • Removes the getParameters in the entities class as I feel like we don't use it and it can be confusing to have different implementations of the same thing. Meaning, I prefer to always do:
    from stlib.visual import Visual, VisualParameters
    def createScene(rootnode):
        rootnode.add(Visual, parameters=VisualParameters())

hugtalbot and others added 19 commits October 28, 2025 09:58
* working deformable entity

* [splib] fixes match case

* [stlib] WIP on extract.py
* Add Sofa.Core.Node.add with preliminary test

* rename the "add" function and make it private

* Apply suggestions from code review

Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

---------

Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
* Reorder files to match concepts

* Put every prefab in root to avoid having a useless prefix

* Fix bad import in bunny example

* Update examples/stlib/PrefabScene_beginner.py

Co-authored-by: EulalieCoevoet <eulalie.coevoet@gmail.com>

---------

Co-authored-by: EulalieCoevoet <eulalie.coevoet@gmail.com>
* cleaning to fix deformable example

* Restore checks on name and add check on the presence of parameters

* Allow to use default parameters (passing nothing to the add method except the class name

---------

Co-authored-by: Paul Baksic <paul.baksic@outlook.fr>
commit 833bd69
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Fri Feb 27 00:40:59 2026 +0100

    [doc] Use sphinx-design in order to fix doc generation (sofa-framework#586)

    Co-authored-by: hugtalbot <hugo.talbot@inria.fr>

commit d982bc8
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Feb 26 23:11:32 2026 +0100

    Remove unappropriate comment (sofa-framework#591)

commit ae7e8e1
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Thu Feb 26 18:39:56 2026 +0100

    Ignore the meshing scenes (sofa-framework#587)

commit 6593f34
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Thu Feb 26 18:38:58 2026 +0100

    [RPyC] Add new exposed methods to SOFA server (sofa-framework#570)

    * Add a way to init the root remotly

    * Add method to change working dir on remote

commit bdbaece
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Thu Feb 26 10:29:37 2026 +0100

    Add python modules that uses the CGAL binding  (sofa-framework#567)

    * Add python modules that uses the CGAL binding instead of the CGALPlugin to generate mesh from a pointcloud or a surfacic polyhedron

    * Add a SOFA scene opening and using the generated mesh with CGAL

    * Sort all files into a meshing repo and add a Gmsh example

    * Make display optionnal

    * Fix typo

    ---------

    Co-authored-by: hugtalbot <hugo.talbot@inria.fr>
    Co-authored-by: Themis Skamagkis <70031729+th-skam@users.noreply.github.com>

commit 617d506
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Thu Feb 26 10:29:13 2026 +0100

    [examples] Add a thermo-elastic example (sofa-framework#204)

    * [examples] Add a thermo-elastic example

    * minor comment to remove

    * Get compatible with sofa-framework#198 and add legend

    * Remove option of topo changes

    * Update scene further to recently introduced templates in Mass

    * avoid using strings

    * update scene with imgui, linkpath etc

    ---------

    Co-authored-by: hugtalbot <hugo.talbot@inria.fr>

commit 4fb7e89
Author: leobois67 <leo.bois@inria.fr>
Date:   Wed Feb 25 18:58:24 2026 +0100

    Example of a ForceField implemented with JAX (sofa-framework#557)

    * Add the example

    * Igne jax example on main CI

    * Fix ignoring the jax examples

    * Fix addKToMatrix() with different options

    * Apply suggestions from code review

    ---------

    Co-authored-by: Paul Baksic <paul.baksic@outlook.fr>
    Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

commit b3a79c6
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Wed Feb 25 15:50:54 2026 +0100

    Fix code block indentation for createScene function (sofa-framework#582)

    Updated code block formatting for createScene function.
    This should fix the doc generation

commit fc75967
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Feb 13 03:42:51 2026 +0100

    fix wrong parameter order in addDForce and addKToMatrix (sofa-framework#579)

    * fix wrong parameter order in addDForce

    * also fix addKToMatrix

commit ca2be7c
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Feb 13 03:42:37 2026 +0100

    Add bindings for prism and pyramid topology functions (sofa-framework#578)

commit 346d298
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Feb 13 03:42:20 2026 +0100

    ordering field is deprecated, use NaturalOrderingMethod instead (sofa-framework#577)

commit 959b4cd
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Feb 13 03:42:02 2026 +0100

    Redirect SOFA logs to Python's sys.stdout using a custom PythonMessageHandler (sofa-framework#576)

    * Redirect SOFA logs to Python's sys.stdout using a custom PythonMessageHandler.

    * cleaning

    * Redirect SOFA logs to Python's sys.stdout using a custom PythonMessageHandler.

commit c0dc30e
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Feb 12 10:43:05 2026 +0100

    Clean getRecords in Timer module (sofa-framework#561)

    * Clean getRecords in Timer module

    * remove extra /**

commit d2ba475
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Feb 4 23:59:52 2026 +0100

    include `sofa/core/fwd.h` instead of the forward declaration (sofa-framework#575)

commit c209f3a
Author: Frederick Roy <fredroy@users.noreply.github.com>
Date:   Wed Feb 4 22:50:20 2026 +0900

    fix mixed-up quote/doublequote, plus consistent quoting (sofa-framework#574)

commit 7760402
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Tue Feb 3 08:05:33 2026 +0100

    Generalize use of initRoot (sofa-framework#566)

    Co-authored-by: hugtalbot <hugo.talbot@inria.fr>

commit b29cfe5
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Jan 29 20:19:43 2026 +0100

    Remove the implementation of getPathName as it is now in BaseData (sofa-framework#556)

    See: sofa-framework/sofa#5759

    Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

commit c7fb254
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Jan 29 20:08:22 2026 +0100

    Introduce an example of a custom message handler (sofa-framework#569)

commit f4e90d4
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Thu Jan 29 09:00:43 2026 +0100

    Follow lifecycle v26.06 deprecated header (sofa-framework#571)

    Co-authored-by: hugtalbot <hugo.talbot@inria.fr>

commit 8bf0162
Author: Frederick Roy <fredroy@users.noreply.github.com>
Date:   Wed Jan 7 06:48:05 2026 +0900

    remove import of scipy.misc, which is deprecated (sofa-framework#564)

commit 1016b94
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Dec 18 16:37:52 2025 +0100

    Update advanced_timer.py with comments and fix deprecated data (sofa-framework#562)

commit 29c4e87
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Tue Dec 16 12:01:32 2025 +0100

    Add example scene using CCDTightInclusion (sofa-framework#559)

    * Add example scene using CCDTightInclusion

    * Replace ProjectedGaussSeidel with BlockGaussSeidel

    * Fix scene error

commit d38d3c4
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Fri Dec 12 11:53:20 2025 +0100

    Apply name changing on code and examples (sofa-framework#560)

commit b09d921
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Nov 13 15:28:05 2025 +0100

    Add Quaternion to python factory so we can create data field with this type. (sofa-framework#555)

commit a66c054
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Nov 13 15:27:48 2025 +0100

    Improve error message when the SetDataFromArray does not match (sofa-framework#554)

    * Improve error message when the SetDataFromArray does not match

    * Apply suggestions from code review

    ---------

    Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

commit 746745c
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Nov 13 15:27:28 2025 +0100

    Add context manager behavior to Node() (sofa-framework#545)

    This allows to use with statment to have good looking indentation in sofa scene.
    eg:
    with Node("YOLO") as w:
    	w.addObject("YY")

commit af98611
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Nov 13 15:25:55 2025 +0100

    Support more types of linear systems (sofa-framework#542)

    * Support more types of linear systems

    * add support for BTD

commit ae6b330
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Nov 13 10:35:28 2025 +0100

    add missing required plugin in test (sofa-framework#558)

commit 6ef05ed
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Tue Nov 11 14:34:26 2025 +0100

    Fix binding after #5648 (sofa-framework#528)

    Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

commit 5029c05
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Thu Nov 6 10:24:24 2025 +0100

    Add validation for numpy array as return type in AddKToMatrix bindings (sofa-framework#541)

    * Add validation for numpy array as return type in AddKToMatrix bindings

    * Refactor AddKToMatrix return type validation and simplify conditional checks

commit 8ba1e2c
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Oct 30 16:06:25 2025 +0100

    Register in the PythonFactory Rigid3::Coord (sofa-framework#544)

    Because currently only Rigid3::VecCoord was supported.

commit 72ed0e6
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Oct 30 16:06:16 2025 +0100

    Add proper return value to event overriden in python (sofa-framework#543)

    Currently the controllers implemented in python cannot report the the event processing
    system in sofa that there is no need anymore to process the event.

    The PR allows to do. Every onXXXXXX() that implement an event processor can no return a value.
    If it is None or False then processing of event use this to continue the propagation
    If it is True (aka: has been processed/no more further), then the SOFA system will not proposed to other component to process the same event
Because currently only Rigid3::VecCoord was supported.
commit b0cffe7
Author: bakpaul <paul.baksic@outlook.fr>
Date:   Tue Mar 3 10:17:06 2026 +0100

    Dump ideas

commit 4baade5
Author: Damien Marchal <damien.marchal@univ-lille1.fr>
Date:   Thu Oct 30 16:06:25 2025 +0100

    Register in the PythonFactory Rigid3::Coord (sofa-framework#544)

    Because currently only Rigid3::VecCoord was supported.

commit dd6865e
Author: bakpaul <paul.baksic@outlook.fr>
Date:   Mon Mar 2 14:26:25 2026 +0100

    Make exctracted topo working'

commit de007a3
Author: Paul Baksic <paul.baksic@outlook.fr>
Date:   Wed Oct 29 17:31:41 2025 +0100

    Added S, but still need to make the free motion not crash

commit d3148a5
Author: Paul Baksic <paul.baksic@outlook.fr>
Date:   Wed Oct 29 12:21:41 2025 +0100

    Fix plane and some splib deprecated components

commit d2c120e
Author: Paul Baksic <paul.baksic@outlook.fr>
Date:   Tue Oct 28 18:22:41 2025 +0100

    Add plane, still need to really implement function + started creating the scene
@bakpaul bakpaul force-pushed the 25_04_work_on_new_prefabs branch from 92dccd9 to 8b239c6 Compare April 8, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants